package com.zhong.bmob.server;

import com.zhong.bmob.inter.IFileUpLoadUserDown;

import java.io.File;

import cn.bmob.v3.datatype.BmobFile;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.UploadFileListener;

/**
 * Created by 俊峰 on 2017/5/16.
 * 用于将文件上传到Bmob
 */

public class FileUpLoad {
    public static void getFilePath(File file, IFileUpLoadUserDown mUserDown){
        final IFileUpLoadUserDown userDown = mUserDown;
        final BmobFile sendFile = new BmobFile(file);
        sendFile.uploadblock(new UploadFileListener() {
            @Override
            public void done(BmobException e) {
                if (e == null) {
                    userDown.upLoadSuccess(sendFile.getFileUrl());
                } else {
                    userDown.upLoadFail(e);
                }
            }
        });
    }
}
